pub struct Solution;

impl Solution {
    pub fn kids_with_candies(candies: Vec<i32>, extra_candies: i32) -> Vec<bool> {
        if let Some(&max) = candies.iter().max() {
            candies
                .into_iter()
                .map(|i| {
                    if i + extra_candies >= max {
                        true
                    } else {
                        false
                    }
                })
                .collect()
        } else {
            vec![]
        }
    }
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn t() {
        let candies = vec![1, 3, 5, 8];
        let extra_candies = 5;
        assert_eq!(
            Solution::kids_with_candies(candies, extra_candies),
            vec![false, true, true, true]
        );
    }
}
